//
//  HomeViewModel.swift
//  七哥直播
//
//  Created by seven on 2017/12/21.
//  Copyright © 2017年 seven. All rights reserved.
//

import UIKit

class HomeViewModel {
    lazy var anchorModels = [AnchorModel]()
}
extension HomeViewModel {
    func loadHomeData(type : HomeType, index : Int,  finishedCallback : @escaping () -> ()){
        NetworkTools.requestData(.get, URLString: "http://qf.56.com/home/v4/moreAnchor.ios", parameters: ["type" : type.type, "index" : index, "size" : 48]) { (result) in
            guard let dictArr = result["message"]["anchors"].arrayObject as? [[String:Any]] else {
                return
            }
            for (index, dict) in dictArr.enumerated() {
                let anchor = AnchorModel(dict: dict)
                anchor.isEvenIndex = index % 2 == 0
                self.anchorModels.append(anchor)
            }
            finishedCallback()
        }
    }
}
